ImagXpress 13 for .NET - User Guide > How To > View an Image > Define Viewer Properties > Set Context Menus |
Each ImageXView object can have one associated context menu, which provides options to the user within the control window. To define a context menu for the viewer, call ImageXView.ContextMenu. The ContextMenu property inherits from System.Windows.Forms.Control. By default, this property is set to an instance of the ImagXpressDefaultContextMenu class. This class provides a default set of menu items that operate on the ImageXView.
The following code example demonstrates how to add a new item to the context menu:
C# Example |
Copy Code
|
---|---|
MenuItem menuBlack = new MenuItem(); menuBlack.Text = "Preserve Black"; menuBlack.Name = "Black"; menuBlack.Checked = false; imageXView1.ContextMenu.MenuItems.Add(6, menuBlack); |
The following code example demonstrates how to remove a menu item from the ImagXpress menu:
C# Example |
Copy Code
|
---|---|
imageXView1.ContextMenu.MenuItems[1].Visible = false;
|
The following code example demonstrates how to connect an event handler to a menu item:
C# Example |
Copy Code
|
---|---|
for (int i = 0; i < imageXView1.ContextMenu.MenuItems.Count; i++) { imageXView1.ContextMenu.MenuItems[i].Click += new EventHandler(ContextMenuClickEventHandler); ///must remove event handler during cleanup code } //event handler private void ContextMenuClickEventHandler(object sender, EventArgs e) { … } |
Each ImageXView object also has one associated toolbar (Toolbar). The toolbar has an associated context menu, which provides application end-users with options for accessing each of the tools. The toolbar context menu is defined using the methods within the ImageXView.Toolbar.ContextMenu.